package com.example.review_generator

import android.content.ClipData
import android.content.ClipboardManager
import android.content.Context
import android.os.Bundle
import android.util.Log
import androidx.appcompat.app.AppCompatActivity
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.show_fragment.*

class MainActivity : AppCompatActivity() {

    //初始化参数
    var name:String="张三"
    var place:String="学校"
    var thing:String="毁坏公物"
    var to_who:String="老师"
    var type:String="school"
    var num:Int=500
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        Log.d("data","onCreat")


        out1.setOnClickListener {
            //开始填充碎片
            supportFragmentManager.beginTransaction().replace(R.id.framelayout,article_show()).commit()
        }

        select.setOnClickListener {
            supportFragmentManager.beginTransaction().replace(R.id.framelayout,Information_select()).commit()
        }

        copy.setOnClickListener {
            init_article()
        }


    }




    fun init_article(){
        //复制到系统剪切板
        val cm:ClipboardManager= getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager
        cm.text=null
        val str: ClipData = ClipData.newPlainText("Label",article.text.toString())

        cm.setPrimaryClip(str)
    }

}

